package cn.kgc.controller;

import cn.kgc.pojo.DevUser;
import cn.kgc.service.DevUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller //定义控制器
@RequestMapping("/dev") //映射URL
public class DevUserController {
    @Resource //自动装配
    private DevUserService devUserService;
    //进入开发者登录的页面
    @RequestMapping("login")
    public String login(){
        return "dev_login";
    }

    //实现登录功能
    @RequestMapping(value = "dologin",method = RequestMethod.POST)
    public String doLogin(@RequestParam String devCode, @RequestParam String devPassword){
        DevUser devUser=devUserService.login(devCode,devPassword);
        if(devUser!=null){
            return "developer/index";
        }
        return "devlogin";
    }
}
